package com.xinyin.aiqinhaiback.config;


import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Map;
@ConfigurationProperties(prefix = "modbus")
public class ModbusConfig {

	private Map<String, DeviceConfig> devices;

	// Getter & Setter
	public Map<String, DeviceConfig> getDevices() {
		return devices;
	}
	public String getIp(String name) {
		// 通过设备名 "cold" 获取 Device 对象
		DeviceConfig device = this.getDevices().get(name);
		if (device == null) {
			throw new IllegalArgumentException("Cold device not found in configuration!");
		}
		return device.getIp();
	}
	public void setDevices(Map<String, DeviceConfig> devices) {
		this.devices = devices;
	}
}
